feat: add expect "..." by print ... command#986
Merged
Conversation
Introduce a top-level command for unit-testing pretty-printer output
from inside `.ec` files:
expect "op foo : int = 1." by print op foo.
The expected string is compared (after `String.trim` on both sides)
against the captured output of the inner `print` command. On mismatch,
raise an `hierror` with the expected and actual blocks; this fails the
enclosing script in the standard way and is picked up by `scripts/testing/runtest`.
Multi-line expected literals are supported out of the box because the
existing STRING lexer rule already accepts embedded newlines.
Also adds tests/expect.ec covering nullary/parametric ops, record
types, axioms, and leading/trailing whitespace tolerance.
fdupress
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a top-level EasyCrypt command for unit-testing pretty-printer
output from inside
.ecfiles:The expected string is compared against the captured output of the
inner
printcommand (trimmed on both sides). On mismatch, anhierroris raised — this fails the enclosing script in the standardway and is picked up by
scripts/testing/runtest.Multi-line expected literals are supported out of the box because the
existing STRING lexer rule already accepts embedded newlines.
Known limitations / possible follow-ups
printis supported as the inner command;search/locatecould be added trivially.String.trim-based: leading/trailing whitespace tolerant, strict on internal whitespace. A stricter/normalized mode could be added.--promote-expectauto-update workflow yet (design discussed, deferred).